package com.sl.crawler.service.task;

import com.sl.crawler.robot.Crawler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by shiling on 2017/6/4.
 */
@Service
public class LianJiaCrawlerTaskService {
    private final static Logger LOG = LoggerFactory.getLogger(LianJiaCrawlerTaskService.class);

    /**
     * 抓取全部信息(房屋,小区)
     */
    public void crawlerAll() {
        crawlerHouse();
        crawlerXiaoqu();
    }

    /**
     * 抓取房屋信息
     */
    public void crawlerHouse() {
        LOG.info("抓取房屋信息开始!");
        try {
            Crawler.crawlerSingle("crawler/lianjia/house.yaml");
        } catch (Exception e) {
            LOG.error("执行定时抓取房屋失败!", e);
        }
        LOG.info("抓取房屋信息结束!");
    }

    /**
     * 抓取小区信息
     */
    public void crawlerXiaoqu() {
        LOG.info("抓取小区信息开始!");
        try {
            Crawler.crawlerSingle("crawler/lianjia/xiaoqu.yaml");
        } catch (Exception e) {
            LOG.error("执行定时抓取小区失败!", e);
        }
        LOG.info("抓取小区信息结束!");
    }
}
